package com.authine.cloudpivot.ext.dto.transfer;

import com.authine.mvp.app.launcher.domain.SelectorFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 采购付款
 * Created by xue on 2018/11/9.
 */
@Data
@Schema(description = "PurchaseRequestPaymentDto")
@ApiModel("采购付款")
public class PurchaseRequestPaymentDto {
    @Schema(description = "采购申请支付ID")
    private String id;
    @Schema(description = "采购申请支付ID集合")
    private List<String> ids;
    @Schema(description = "供应商ID")
    private String vendor_id;
    @Schema(description = "销售总金额")
    private BigDecimal sale_amount;
    @Schema(description = "销售总金额(未)")
    private BigDecimal pre_sale_amount;
    @Schema(description = "采购总金额")
    private BigDecimal purchase_amount;
    @Schema(description = "采购总金额(未)")
    private BigDecimal pre_purchase_amount;
    @Schema(description = "付款金额")
    private BigDecimal payment_amount;
    @Schema(description = "付款金额(未)")
    private BigDecimal pre_payment_amount;
    @Schema(description = "付款状态")
    //    private PurchaseRequestEnum status;
    private String purchase_payment_status;
    @Schema(description = "备注")
    private String memo;
    @Schema(description = "采购付款明细")
    private List<PurchaseRequestPaymentDetailDto> paymentDetails;
    @Schema(description = "申请人ID")
    private SelectorFormat applicant_id;
    @Schema(description = "申请人名称")
    private String applicant_name;
    @Schema(description = "审批备注")
    private String approve_comments;
    @Schema(description = "转采管理-采购付款-审核:是否通过")
    private Boolean is_pass;

    public PurchaseRequestPaymentDto() {
    }

    public Map<String, Object> beanToMap(PurchaseRequestPaymentDto dto) {

        Map<String, Object> purchaseRequestPayment = new HashMap<>();
        purchaseRequestPayment.put("vendor_id",dto.getVendor_id());
        purchaseRequestPayment.put("sale_amount",dto.getSale_amount());
        purchaseRequestPayment.put("pre_sale_amount",dto.getPre_sale_amount());
        purchaseRequestPayment.put("purchase_amount",dto.getPurchase_amount());
        purchaseRequestPayment.put("pre_purchase_amount",dto.getPre_purchase_amount());
        purchaseRequestPayment.put("payment_amount",dto.getPayment_amount());
        purchaseRequestPayment.put("pre_payment_amount",dto.getPre_payment_amount());
        return purchaseRequestPayment;
    }

    //采购申请付款
    /*public static PurchaseRequestPaymentEntity toPurchaseRequestPaymentEntity(PurchaseRequestPaymentDto purchaseRequestPaymentVO) {
        List<PurchaseRequestPaymentDetailEntity> purchaseRequestPaymentDetailEntities = new ArrayList<>();
        List<PurchaseRequestPaymentDetailDto> purchaseRequestPaymentDetailVOS = purchaseRequestPaymentVO.getPaymentDetailVoS();
        for (PurchaseRequestPaymentDetailDto purchaseRequestPaymentDetail : purchaseRequestPaymentDetailVOS) {
            //循环遍历明细
            PurchaseRequestPaymentDetailEntity purchaseRequestPaymentDetailEntity =purchaseRequestPaymentDetail.toPurchaseRequestPaymentDetailEntity(purchaseRequestPaymentDetail) ;
            purchaseRequestPaymentDetailEntities.add(purchaseRequestPaymentDetailEntity);
        }
        return new PurchaseRequestPaymentEntity(purchaseRequestPaymentDetailEntities,purchaseRequestPaymentVO.getVendorId(),purchaseRequestPaymentVO.getMoreSaleAmount(),purchaseRequestPaymentVO.getPreMoreSaleAmount()
                ,purchaseRequestPaymentVO.getMorePurchaseAmount(),purchaseRequestPaymentVO.getPreMorePurchaseAmount(),
                purchaseRequestPaymentVO.getMorePaymentAmount(),purchaseRequestPaymentVO.getPreMorePaymentAmount(),null==purchaseRequestPaymentVO.getStatus()?PurchaseRequestEnum.NEW:purchaseRequestPaymentVO.getStatus(),
                purchaseRequestPaymentVO.getMemo()
        );
    }*/
}
